home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
152_01
/
xc.c
< prev
next >
Wrap
Text File
|
1985-03-09
|
26KB
|
956 lines
/*
HEADER: CUG152.10;
TITLE: A "C" concordance or cross-reference
utility documentation;
DATE: 09/04/85;
DESCRIPTION:
"A utility to develop lists of reserved words in source code
to form a concordance or cross-reference of the program."
KEYWORDS: concordance, cross-refernce;
FILENAME: XC.C;
WARNINGS:
"The typist of this heading does not have equipment to run
this program and prepared this header from comments
within the source code or companion files."
The authors claim copyrights and authorize non-commercial
use only."
AUTHORS: Philip N. Hisley
David N. Smith;
COMPILERS: CI/C86;
REFERENCES:
AUTHERS: " ";
TITLE: " ";
CITATION: " ";
ENDREF
*/
/**********************************************************
XC - A 'C' Concordance Utility
Version 1.0 January, 1982
Copyright (c) 1982 by Philip N. Hisley
Philip N. Hisley
548H Jamestown Court
Edgewood, Maryland 21040
(301) 679-4606
Released for non-commercial distribution only
Converted to IBM/PC CI/C86 by David N. Smith, May/June 1983
with enhancements and Lattice compiler support in December 1983.
David N. Smith
44 Ole Musket Lane
Danbury, CT 06810
(203) 748-5934
CompuServe: 73145,153
Changes Copyright (c) 1983 by David N. Smith
Permission granted to copy for non-commercial purporses.
PC Enhancements include:
1) Nested #INCLUDE statements
2) Single spaced cross-reference list
3) Removal of tabbing on output device
(Since many printers don't support it)
4) #INCLUDE statements with both "--" and <-->
syntax and with a full fileid in the quotes.
5) Multiple input filenames on command line.
Abstract:
'XC' is a cross-reference utility for 'C' programs.
Its has the ability to handle nested include files
to a depth of 8 levels and properly processes nested
comments as supported by BDS C. Option flags support
the following features:
- Routing of list output to disk
- Cross-referencing of reserved words
- Processing of nested include files
- Generation of listing only
Usage: xc <filename> <flag(s)>
Flags: -i = Enable file inclusion
-l = Generate listing only
-r = Cross-ref reserved words
-o <filename> = Write output to named file
***********************************************************/
#include "e:stdio.h"
/* Compiler specific stuff */
#define Lattice
#ifdef Lattice
#include "e:ctype.h"
#endif
/* end compiler specific section */
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define ERROR -1
#define MAX_REF 5 /* maximum refs per ref-block */
#define MAX_LEN 20 /* maximum identifier length */
#define MAX_WRD 749 /* maximum number of identifiers */
#define MAX_ALPHA 53 /* maximum alpha chain heads */
#define REFS_PER_LINE 10 /* maximum refs per line */
#define LINES_PER_PAGE 60
#define MAXCOL 78 /* default maximum column number for listing line */
#define MINCOL 30 /* minimum value for -w option */
#define FF 0x0C /* formfeed */
struct rf_blk {
int ref_item[MAX_REF];
int ref_cnt;
} onerf;
struct id_blk {
char id_name[MAX_LEN];
struct id_blk *alpha_lnk;
struct rf_blk *top_lnk;
struct rf_blk *lst_lnk;
} oneid;
struct id_blk *id_vector[MAX_WRD];
struct alpha_hdr { struct id_blk *alpha_top;
struct id_blk *alpha_lst;
};
struct alpha_hdr alpha_vector[MAX_ALPHA];
int linum; /* line number */
int edtnum; /* edit line number */
int fil_cnt; /* active file index */
int wrd_cnt; /* token count */
int pagno; /* page number */
int id_cnt; /* number of unique identifiers */
int rhsh_cnt; /* number of conflict hits */
int filevl; /* file level */
int paglin; /* page line counter */
int dummy; /* dummy integer */
int maxcol=MAXCOL; /* maximum right column for listing line */
int prt_ref;
char act_fil[MAX_LEN];
char lst_fil[MAX_LEN];
char gbl_fil[MAX_LEN];
FILE *f_lst_fil;
int i_flg,
o_flg,
r_flg,
l_flg;
long atoi();
/*************************************************************************/
main(p_argc, p_argv)
int p_argc;
char **p_argv;
{
char *arg;
int argc;
char **argv;
char c;
int i;
argc = p_argc;
argv = p_argv;
if (argc < 2) use_err();
i_flg=r_flg=o_flg=l_flg=FALSE;
while(--argc != 0)
{ if(*(arg=*++argv) == '-')
{switch(*++arg)
{
case 'i':
case 'I': i_flg++;
break;
case 'r':
case 'R': r_flg++;
break;
case 'l':
case 'L': l_flg++;
break;
case 'o':
case 'O': { o_flg++;
if(--argc == 0) use_err();
strcpy(lst_fil,*++argv);
if(lst_fil[0] == '-') use_err();
break;}
case 'w':
case 'W': { if(--argc == 0) use_err();
i = atoi(*++argv);
if( i<=MINCOL || i>=255 ) use_err();
maxcol = i;
break;
}
default: use_err();
}
}
}
if(o_flg)
{if( (f_lst_fil=fopen(lst_fil,"w")) == NULL)
{ printf("ERROR: Unable to create list file - %s\n",lst_fil);
exit(0);}
printf("XC ... 'C' Concordance Utility v1.0\n\n");
}
prt_ref = FALSE;
for(linum=0;linum < MAX_WRD;linum++) {
id_vector[linum] = NULL; }
for(linum=0;linum < MAX_ALPHA;linum++)
{
alpha_vector[linum].alpha_top =
alpha_vector[linum].alpha_lst = NULL;
}
fil_cnt = wrd_cnt = linum = 0;
filevl=paglin=pagno=edtnum=0;
id_cnt=rhsh_cnt=0;
argc = p_argc; argc--;
argv = p_argv;
while(argc--) {
strcpy(gbl_fil,*++argv);
if(*gbl_fil == '-') break;
proc_file(gbl_fil,dummy);
}
if(!l_flg) {
gbl_fil[0] = '\0';
prnt_tbl();
printf("\nAllowable Symbols: %d\n",MAX_WRD);
printf("Unique Symbols: %d\n",id_cnt);}
if(o_flg) {
nl();
/* if(fprintf(f_lst_fil,"%c",CPMEOF) == ERROR) lst_err(); */
fclose(f_lst_fil);
}
}
/*************************************************************************/
lst_err()
{ printf("\nERROR: Write error on list output file - %s\n",
lst_fil);
exit(0);
}
/*************************************************************************/
use_err()
{ printf("\nERROR: Invalid parameter specification\n\n");
printf("Usage: xc <filename>... <flag(s)>\n\n");
printf("Flags: -i = Enable file inclusion\n");
printf(" -l = Generate listing only\n");
printf(" -r = Cross-reference reserved words\n");
printf(" -o <outfile> = Write output to named file\n");
printf(" -w width = Width of output page; default=78\n");
printf("Flags must follow all input file names");
exit(0); }
/***********************